package com.knife.generator;

import com.alibaba.fastjson.JSONArray;

/**
 * create by yongli on 2021-12-30 10:01
 * 修改库存数量
 */

public class SqlGen2 {
    public static void main(String[] args) {
        String template ="update sany_heavy_energy.spw_accessory_library  set  INVENTORY_QUANTITY =100" +
                " WHERE factory_CODE =\"5600\" and warehouse_code=\"8000\" and MATERIAL_CODE =\"arg1\";";
        String data= "[{\"code\":\"170101020013A\",\"num\":\"36\"},{\"code\":\"170105020002A\",\"num\":\"12\"},{\"code\":\"61003068\",\"num\":\"12\"},{\"code\":\"60317926\",\"num\":\"48\"},{\"code\":\"170103020027A\",\"num\":\"75\"},{\"code\":\"170105040002A\",\"num\":\"15\"},{\"code\":\"170103020023A\",\"num\":\"75\"},{\"code\":\"170103010049A\",\"num\":\"15\"}]";
        JSONArray  array = JSONArray.parseArray(data);
        for(int i=0;i<array.size();i++){
           String code = array.getJSONObject(i).getString("code");
           String num = array.getJSONObject(i).getString("num");
           String templte2 = template;
           templte2 = templte2.replace("100",num).replace("arg1",code);
           System.out.println(templte2);
        }

    }
}
